package com.pxst.internalReports.controller;


import com.pxst.merchant.service.SysMerchantIncomeStatisticsService;
import com.pxst.resp.ApiResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author Chrissy
 * @description 商户每日结算相关接口
 * @since 2023-11-13 18:55:32
 */
@Api(tags = "商户每日结算相关接口")
@RestController
@RequestMapping("/internal/dailyBalance")
public class DailyBalanceController {
    @Resource
    private SysMerchantIncomeStatisticsService service;


    @ApiOperation(value = "商户每日结算搜索接口")
    @GetMapping("/searchDailyBalance")
    public ApiResp searchDailyBalance(@RequestParam("year") @NotNull(message = "年份不能为空") Integer year, @RequestParam("month") @NotNull(message = "月份不能为空") Integer month
            , @RequestParam("currency") @NotBlank(message = "币种不能为空") String currency, @RequestParam("merchantId") List<Long> merchantId) {
        return ApiResp.sucess(service.searchDailyBalance(year, month, currency, merchantId));
    }

    @ApiOperation(value = "商户每日结算汇出报表接口")
    @GetMapping("/downloadDailyBalance")
    public void downloadDailyBalance(@RequestParam("year") @NotNull(message = "年份不能为空") Integer year, @RequestParam("month") @NotNull(message = "月份不能为空") Integer month
            , @RequestParam("currency") @NotBlank(message = "币种不能为空") String currency, @RequestParam("merchantId") List<Long> merchantId, HttpServletResponse response) {
        service.downloadDailyBalance(year, month, currency, merchantId,response);
    }
}
